//
//  AnswerViewController.m
//  Hxcsfw
//
//  Created by qiysoft on 2017/10/26.
//  Copyright © 2017年 企友软mac. All rights reserved.
//

#import "AnswerViewController.h"
#import "AnswerCell.h"
#define AnswerCellIndentifier @"AnswerCellIndentifier"
#import "SBCell.h"
#define SBCellIndentifier @"SBCellIndentifier"
#import "VideoDetailViewController.h"
#import "STSegmentView.h"
#import "SBViewController.h"
#import "KPViewController.h"
#import "RZViewController.h"
#import "CSViewController.h"
#import "BSViewController.h"
#import "CSZXViewController.h"
#import "LoginViewController.h"
#import "ChangePsdViewController.h"
#import "SearchViewController.h"
#import "WDWTViewController.h"
#import "WDKCViewController.h"
#import "WDXXViewController.h"
#import "WWebViewController.h"
#import "AnswerModel.h"
#import "AnswerTJModel.h"
#import "WWebViewController.h"
#import "AFSoundManager.h"
#import "AnswerSortViewController.h"
#import "SBFLCell.h"
#import "KPFLCell.h"
#import "RZFLCell.h"
#import "CSFLCell.h"
#import "BSFLCell.h"
#define SBFLCellIndentifier @"SBFLCellIndentifier"
#define KPFLCellIndentifier @"KPFLCellIndentifier"
#define RZFLCellIndentifier @"RZFLCellIndentifier"
#define CSFLCellIndentifier @"CSFLCellIndentifier"
#define BSFLCellIndentifier @"BSFLCellIndentifier"
#import "AnswerSortListViewController.h"
#import "LoginViewController.h"
#import "DiagramDetailViewController.h"
#import "DiagramViewController.h"
#import "DiagramModel.h"
#import "CheckNetwork.h"

@interface AnswerViewController ()<UITableViewDelegate,UITableViewDataSource,UIScrollViewDelegate,STSegmentViewDelegate,TermCellDelegate,AnswerCellDelegate>
{
    AnswerCell *cell1;
    SBCell *cell2;
    SBFLCell *cell3;
    KPFLCell *cell4;
    RZFLCell *cell5;
    CSFLCell *cell6;
    BSFLCell *cell7;

    UIView *headerView;
    BOOL isA;
    UIView *firstView; // Cell第一行的视图
    BOOL BF;
    NSURL *previousURL;
    UILabel *quanJuLb;
    UIButton *quanJuBt;
    int j;
    UIImageView *NavimgView;
    
    UIView *viewContent;
    UIView *bgMebemView;
    CGFloat cellTitH;

    NSInteger markIndex;
}

@property (nonatomic,strong) UIScrollView *homeScrollView;
@property (nonatomic,strong) STSegmentView *titScrollView;
@property (nonatomic,strong) NSMutableArray *WenBaListArray;
@property (nonatomic,strong) NSMutableArray *WenBaTJListArray;
@property (nonatomic,copy) NSString *level2;
@property (nonatomic,copy) NSString *level;

@end

@implementation AnswerViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
    
    NavimgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"wenba_title"]];
    NavimgView.frame = CGRectMake(WSCREENH_WIDTH/2-53.5, 15, 107, 15);
    [self.navigationController.navigationBar addSubview:NavimgView];
}

-(void)CSZXNOTICE {
    CSZXViewController *cszxVC = [[CSZXViewController alloc]init];
    cszxVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:cszxVC animated:NO];
}
-(void)WBWDWTNOTICE {

    WWebViewController *webVc = [[WWebViewController alloc] init];
    webVc.strTitle = @"我的问题";
    NSDictionary *parametersDict = @{@"mode":@"web",@"service":@"wdwt",@"content":@{@"username":[WShareUtil sharedData].dicSession[@"nsrsbh"]}};
    NSString *strUrl = [NSString stringWithFormat:@"%@?params=",[WShareUtil getServerURL:nil]];
    webVc.strUrl = [WShareUtil webUrlAppendingString:strUrl dic:parametersDict];
    [self.navigationController pushViewController:webVc animated:NO];

}
- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];
//    self.navigationItem.title = @"有问题, 来问吧";
    [self requestTJWB];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(CSZXNOTICE) name:@"CSZX" object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(WBWDWTNOTICE) name:@"WBWDWT" object:nil];
    
    BF = NO;
    previousURL = [NSURL URLWithString:@"http://www.sx95113.com"];
    // 1.注册控件
    UINib *cellNib = [UINib nibWithNibName:@"AnswerCell" bundle:nil];
    [self.myTableView registerNib:cellNib forCellReuseIdentifier:AnswerCellIndentifier];
    //    _myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.prototypeCell = [self.myTableView dequeueReusableCellWithIdentifier:AnswerCellIndentifier];
    
    // 2.注册控件
    UINib *cellNib2 = [UINib nibWithNibName:@"SBCell" bundle:nil];
    [self.myTableView registerNib:cellNib2 forCellReuseIdentifier:SBCellIndentifier];
    //    _myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.prototypeCell  = [self.myTableView dequeueReusableCellWithIdentifier:SBCellIndentifier];
    
    // 3.注册控件
    UINib *cellNib3 = [UINib nibWithNibName:@"SBFLCell" bundle:nil];
    [self.myTableView registerNib:cellNib3 forCellReuseIdentifier:SBFLCellIndentifier];
    //    _myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.prototypeCell  = [self.myTableView dequeueReusableCellWithIdentifier:SBFLCellIndentifier];
    
    // 4.注册控件
    UINib *cellNib4 = [UINib nibWithNibName:@"KPFLCell" bundle:nil];
    [self.myTableView registerNib:cellNib4 forCellReuseIdentifier:KPFLCellIndentifier];
    //    _myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.prototypeCell  = [self.myTableView dequeueReusableCellWithIdentifier:KPFLCellIndentifier];
    
    // 5.注册控件
    UINib *cellNib5 = [UINib nibWithNibName:@"RZFLCell" bundle:nil];
    [self.myTableView registerNib:cellNib5 forCellReuseIdentifier:RZFLCellIndentifier];
    //    _myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.prototypeCell  = [self.myTableView dequeueReusableCellWithIdentifier:RZFLCellIndentifier];
    
    // 6.注册控件
    UINib *cellNib6 = [UINib nibWithNibName:@"CSFLCell" bundle:nil];
    [self.myTableView registerNib:cellNib6 forCellReuseIdentifier:CSFLCellIndentifier];
    //    _myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.prototypeCell  = [self.myTableView dequeueReusableCellWithIdentifier:CSFLCellIndentifier];
    
    // 7.注册控件
    UINib *cellNib7 = [UINib nibWithNibName:@"BSFLCell" bundle:nil];
    [self.myTableView registerNib:cellNib7 forCellReuseIdentifier:BSFLCellIndentifier];
    //    _myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.prototypeCell  = [self.myTableView dequeueReusableCellWithIdentifier:BSFLCellIndentifier];
    
    _level2 = [WShareUtil sharedData].strLevel;
    if (_level2 == nil) {
        _level2 = @"sb";
    }
    _level = [WShareUtil sharedData].strLevel2;
    if ([WShareUtil strNilOrEmpty:_level]) {
        _level = @"tech";
    }
    _WenBaListArray = [NSMutableArray array];
    _WenBaTJListArray = [NSMutableArray array];
    
    /*缓存*/
    NSArray *arrReturn = [WShareUtil readModelDataFromFile:@"WenBaListArray"];
    if (arrReturn != nil && arrReturn.count > 0) {
        for (NSDictionary *dic in arrReturn) {
            AnswerModel *answerModel = [AnswerModel mj_objectWithKeyValues:dic];
            [self.WenBaListArray addObject:answerModel];
        }
    }
    
    [self AnswerVCDataRequest];
    [self WenBaTuJieDataRequest];
    
    SBViewController *sbViewController = [[SBViewController alloc]init];
    [self addChildViewController:sbViewController];
    
    KPViewController *kpViewController = [[KPViewController alloc]init];
    [self addChildViewController:kpViewController];
    
    RZViewController *rzViewController = [[RZViewController alloc]init];
    [self addChildViewController:rzViewController];
    
    CSViewController *csViewController = [[CSViewController alloc]init];
    [self addChildViewController:csViewController];
    
    BSViewController *bsViewController = [[BSViewController alloc]init];
    [self addChildViewController:bsViewController];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cellBtnClick:) name:@"dd" object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(PushAnswerSortListViewController) name:@"WenBaNotification" object:nil];//列表下分类跳转通知
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(FLJS:) name:@"WenBaMoreNotification" object:nil];//跳转问题分类页通知

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(WBQXNOTICE) name:@"AWBQX" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(removeAWBQX) name:@"LogoutSucceed" object:nil];
}

// 删除指定通知
- (void)removeAWBQX {
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"AWBQX" object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(WBQXNOTICE) name:@"AWBQX" object:nil];

}

//搜索
-(void)SS:(UIButton *)button {
    
    SearchViewController *searchVC = [[SearchViewController alloc]init];
    searchVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:searchVC animated:NO];
    
}
//在线客服
-(void)ZXKF:(UIButton *)button{

//    WWebViewController *webVc = [[WWebViewController alloc] init];
//    webVc.strTitle = @"在线客服";
//    webVc.strUrl = @"http://www.sobot.com/chat/pc/index.html?sysNum=79f43fe7ebd049898175758d0b00d986";
//    [self.navigationController pushViewController:webVc animated:YES];
    
    [self openMemberSheet];
}
//财税咨询
-(void)CSZX:(UIButton *)button{
    WLog(@"咨询");
    
    if ([WShareUtil sharedData].dicSession) {
        CSZXViewController *cszxVC = [[CSZXViewController alloc]init];
        cszxVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:cszxVC animated:YES];
        
    }else{
        [WShareUtil sharedData].Who = @"CSZX";
        LoginViewController *loginVc = [[LoginViewController alloc] init];
        [self.navigationController pushViewController:loginVc animated:YES];
    }

}
//问题分类
-(void)FLJS:(UIButton *)button{
    WLog(@"问题分类");
    
    AnswerSortViewController *asVC = [[AnswerSortViewController alloc]init];
    asVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:asVC animated:YES];
}
//我的问题
-(void)WDWT:(UIButton *)button{
    
    WWebViewController *webVc = [[WWebViewController alloc] init];
    webVc.strTitle = @"我的问题";
    if ([WShareUtil sharedData].dicSession) {
        
        NSDictionary *parametersDict = @{@"mode":@"web",@"service":@"wdwt",@"content":@{@"username":[WShareUtil sharedData].dicSession[@"nsrsbh"]}};
        NSString *strUrl = [NSString stringWithFormat:@"%@?params=",[WShareUtil getServerURL:nil]];
        webVc.strUrl = [WShareUtil webUrlAppendingString:strUrl dic:parametersDict];
        [self.navigationController pushViewController:webVc animated:YES];
        
    } else {
//        [SVProgressHUD showImage:nil status:@"请先登录"];
//        [SVProgressHUD setOffsetFromCenter:UIOffsetMake(0, WSCREENH_HEIGHT *0.5 - 70)];
//        [SVProgressHUD dismissWithDelay:1.];
//        [SVProgressHUD setBackgroundColor:[UIColor colorWithRed:0.9 green:0.91 blue:0.93 alpha:1]];   //背景颜色
        [WShareUtil sharedData].Who = @"WBWDWT";
        LoginViewController *loginVc = [[LoginViewController alloc] init];
        [self.navigationController pushViewController:loginVc animated:YES];
        
//        [self.navigationController pushViewController:webVc animated:YES];
    }
    
    //    //我的课程
    //    WDKCViewController *wdkcVC = [[WDKCViewController alloc]init];
    //    wdkcVC.hidesBottomBarWhenPushed = YES;
    //    [self.navigationController pushViewController:wdkcVC animated:YES];
    
    //    //我的消息
    //    WDXXViewController *wdxxVC = [[WDXXViewController alloc]init];
    //    wdxxVC.hidesBottomBarWhenPushed = YES;
    //    [self.navigationController pushViewController:wdxxVC animated:YES];
    
    //    //修改密码
    //    ChangePsdViewController *cpsdViewController = [[ChangePsdViewController alloc]init];
    //    cpsdViewController.hidesBottomBarWhenPushed = YES;
    //    [self.navigationController pushViewController:cpsdViewController animated:YES];
}
//问吧图解
- (void)WBTJ:(UIButton *)button {

    /*
    DiagramViewController *diagramVc = [[DiagramViewController alloc]init];
    diagramVc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:diagramVc animated:YES];
     */
    
    DiagramDetailViewController *diagramDetailVc = [[DiagramDetailViewController alloc] init];
    diagramDetailVc.title = @"图解问吧";
    diagramDetailVc.index = 0;
    
    if ([WShareUtil sharedData].arrMdiagram.count >0) {
        
    if ([WShareUtil sharedData].arrMdiagram[0]) {
        
        diagramDetailVc.strTitle = [[WShareUtil sharedData].arrMdiagram[0] strTitle];//分享标题
        diagramDetailVc.strImage = [[WShareUtil sharedData].arrMdiagram[0] imgsrc];//分享图片
        
        NSString *strContent = [[WShareUtil sharedData].arrMdiagram[0] strContent];
        NSArray *array = [strContent componentsSeparatedByString:@"img src=\""];
        strContent = [array[1] componentsSeparatedByString:@"\""][0];
        diagramDetailVc.strUrl = strContent; //分享外链
    }
    
    [self.navigationController pushViewController:diagramDetailVc animated:YES];
    }else{
        [WShareUtil showAlert:@"提示" message:@"暂无数据!"];
    }
}
- (void)SB:(UIButton *)button {
    WLog(@"申报");
    _level2 = @"sb";
    _level = @"tech";
    [_WenBaListArray removeAllObjects];
    [self requestListDataStrNum:@"1" isRefresh:YES];
}
- (void)KP:(UIButton *)button {
    WLog(@"开票");
    _level2 = @"kp";
    _level = @"tech";
    [_WenBaListArray removeAllObjects];
    [self requestListDataStrNum:@"1" isRefresh:YES];
}
- (void)RZ:(UIButton *)button {
    WLog(@"认证");
    _level2 = @"rz";
    _level = @"tech";
    [_WenBaListArray removeAllObjects];
    [self requestListDataStrNum:@"1" isRefresh:YES];
}
- (void)CS:(UIButton *)button {
    WLog(@"财税");
    _level2 = @"";
    _level = @"tax";
    [_WenBaListArray removeAllObjects];
    [self requestListDataStrNum:@"1" isRefresh:YES];
}
- (void)BS:(UIButton *)button {
    WLog(@"办税");
    _level2 = @"";
    _level = @"note";
    [_WenBaListArray removeAllObjects];
    [self requestListDataStrNum:@"1" isRefresh:YES];
}

- (void)cellBtnClick:(NSNotification *)notific {

    NSString *strLevel = notific.userInfo[@"strLevel"];
    NSString *strLevel2 = notific.userInfo[@"strLevel2"];

    if ([strLevel isEqualToString:@"sb"]) {
        [self SB:cell1.SBBtn];
    }else if ([strLevel isEqualToString:@"kp"]) {
        [self KP:cell1.KPBtn];
    }else if ([strLevel2 isEqualToString:@"tax"]) {
        [self CS:cell1.CSBtn];
    }else if ([strLevel2 isEqualToString:@"note"]) {
        [self BS:cell1.BSBtn];
    }
}

#pragma mark - 问吧图解数据
- (void)WenBaTuJieDataRequest {
    
    //mode:native,service:fwwb,content:{revert: }
    NSDictionary *parametersDict = @{@"mode":@"native",@"service":@"fwwb",@"content":@{@"revert":@"init"}};
    NSString *secret = [NSString stringWithFormat:@"%@",[WHttpTool convertToJsonData:parametersDict]];
    //    NSDictionary *paramsDic = @{@"params":[CommonFunc encryptWithText:secret]};
    
    [WHttpTool POST:[WShareUtil getServerURL:nil] parameters:@{@"params":[CommonFunc encryptWithText:secret]} success:^(id responseObject) {
        WLog(@"------%@",responseObject);
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *JsonDic = [WHttpTool dictionaryWithJsonString:responseStr];
        NSString *messageStr = [JsonDic objectForKey:@"message"];
        NSString *successStr = [JsonDic objectForKey:@"success"];
        // 解密请求回的数据（字典）
        NSString *returnStr = [CommonFunc decryptWithText:messageStr];

        // json字符串转字典
        NSDictionary *returnDic = [WHttpTool dictionaryWithJsonString:returnStr];

        WLog(@"%@",returnDic[@"tpwb"]);
        for (NSDictionary *dic in returnDic[@"tpwb"]) {
            AnswerTJModel *answerTJModel = [AnswerTJModel mj_objectWithKeyValues:dic];
            [self.WenBaTJListArray addObject:answerTJModel];
        }
        WLog(@"%@",_WenBaTJListArray);
        [_myTableView reloadData];
        
    } failure:^(NSError *error) {
        WLog(@"失败");
    } showProgress:YES];
    
}

- (void)AnswerVCDataRequest {
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(noWifiRefershingEnd) name:REFRESHINGEND object:nil];
    
    self.myTableView.header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        
        [self requestListDataStrNum:@"1" isRefresh:YES];
        j = 1;
    }];
    
//    if (kIsHaveNetwork) //有网
//    {
//        [_myTableView.header beginRefreshing];
//    } //else无网
    [_myTableView.header beginRefreshing];

//    self.myTableView.footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
//
//        NSString *num = [NSString stringWithFormat:@"%d",++j];
//        [self requestListDataStrNum:num isRefresh:NO];
//    }];
}
- (void)noWifiRefershingEnd {
    [self.myTableView.header endRefreshing];
    [self.myTableView.footer endRefreshing];
    [WShareUtil sharedData].isShowWait = YES;

}

#pragma mark - 下载列表数据
- (void)requestListDataStrNum:(NSString *)pageNum isRefresh:(BOOL)isRefresh {

    [WShareUtil sharedData].isShowWait = YES;

    //mode:native,service:fwwb,content:{revert:paginate,level:tech,level2:sb,pagesize:?,pagenumber:?}
    NSDictionary *parametersDict = @{@"mode":@"native",@"service":@"fwwb",@"content":@{@"revert":@"paginate",@"level":_level,@"level2":_level2,@"pagesize":@"6",@"pagenumber":pageNum}};
    NSString *secret = [NSString stringWithFormat:@"%@",[WHttpTool convertToJsonData:parametersDict]];
    //    NSDictionary *paramsDic = @{@"params":[CommonFunc encryptWithText:secret]};
    
    [WHttpTool POST:[WShareUtil getServerURL:nil] parameters:@{@"params":[CommonFunc encryptWithText:secret]} success:^(id responseObject) {
        WLog(@"------%@",responseObject);
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *JsonDic = [WHttpTool dictionaryWithJsonString:responseStr];
        NSString *messageStr = [JsonDic objectForKey:@"message"];
        NSString *successStr = [JsonDic objectForKey:@"success"];
        // 解密请求回的数据（字典）
        NSString *returnStr = [CommonFunc decryptWithText:messageStr];

        // json字符串转字典
        NSDictionary *returnDic = [WHttpTool dictionaryWithJsonString:returnStr];
        
        if (isRefresh) {
            [self.WenBaListArray removeAllObjects];
        }
        WLog(@"%@",returnDic[@"data"]);
        if ([returnDic[@"data"] count] > 0) {

            for (NSDictionary *dic in returnDic[@"data"]) {
                AnswerModel *answerModel = [AnswerModel mj_objectWithKeyValues:dic];
                [self.WenBaListArray addObject:answerModel];
            }

            [WShareUtil removeModelDataWithFile:@"WenBaListArray"];
            [WShareUtil saveModelData:self.WenBaListArray WithFile:@"WenBaListArray"];
        }else {
            /*缓存*/
            NSArray *arrReturn = [WShareUtil readModelDataFromFile:@"WenBaListArray"];
            if (arrReturn != nil && arrReturn.count > 0) {
                for (NSDictionary *dic in arrReturn) {
                    AnswerModel *answerModel = [AnswerModel mj_objectWithKeyValues:dic];
                    [self.WenBaListArray addObject:answerModel];
                }
            }
        }

        [_myTableView reloadData];
        [self.myTableView.header endRefreshing];
        [self.myTableView.footer endRefreshing];
        
        ///* --- 图片式提醒
//        UIView *view = [self.myTableView viewWithTag:10000];
//        [view removeFromSuperview];
//        HHNonePage *_nonePage = [[HHNonePage alloc]init];
//        _nonePage = nil;
//        if (_WenBaListArray.count == 0) {
//            _nonePage = [[HHNonePage alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
//            _nonePage.tag = 10000;
//            [self.myTableView addSubview:_nonePage];
//        }
        //*/
        if ([returnDic[@"data"] count] < 10) {
            // 拿到当前的上拉刷新控件，变为没有更多数据的状态
            [self.myTableView.footer endRefreshingWithNoMoreData];
        }
        
    } failure:^(NSError *error) {
        WLog(@"失败");
        [self noWifiRefershingEnd];
    } showProgress:YES];
    
}


//设置UITableViewCell的数据
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        cell1  = [[[NSBundle mainBundle] loadNibNamed:@"AnswerCell" owner:self options:nil] lastObject];
        cell1.selectionStyle = UITableViewCellSelectionStyleNone;
        cell1.delegate = self;
        
        if (self.WenBaTJListArray.count > 0 && self.WenBaTJListArray != nil) {
            [cell1.WBTJBtn setTitle:[self.WenBaTJListArray[indexPath.row] strTitle] forState:UIControlStateNormal];
            
        }
        
        if ([_level2 isEqualToString:@"sb"]) {
            cell1.line1.hidden = NO;
            cell1.line2.hidden = YES;
            cell1.line3.hidden = YES;
            cell1.line4.hidden = YES;
            cell1.line5.hidden = YES;
            [cell1.SBBtn setTitleColor:[UIColor colorWithRed:0.97 green:0.38 blue:0.28 alpha:1] forState:UIControlStateNormal];
            [cell1.KPBtn setTitleColor:[UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] forState:UIControlStateNormal];
            [cell1.RZBtn setTitleColor:[UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] forState:UIControlStateNormal];
            [cell1.CSBtn setTitleColor:[UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] forState:UIControlStateNormal];
            [cell1.BSBtn setTitleColor:[UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] forState:UIControlStateNormal];
        }else if ([_level2 isEqualToString:@"kp"]) {
            cell1.line1.hidden = YES;
            cell1.line2.hidden = NO;
            cell1.line3.hidden = YES;
            cell1.line4.hidden = YES;
            cell1.line5.hidden = YES;
            [cell1.SBBtn setTitleColor:[UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] forState:UIControlStateNormal];
            [cell1.KPBtn setTitleColor:[UIColor colorWithRed:0.97 green:0.38 blue:0.28 alpha:1] forState:UIControlStateNormal];
            [cell1.RZBtn setTitleColor:[UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] forState:UIControlStateNormal];
            [cell1.CSBtn setTitleColor:[UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] forState:UIControlStateNormal];
            [cell1.BSBtn setTitleColor:[UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] forState:UIControlStateNormal];
        }else if ([_level2 isEqualToString:@"rz"]) {
            cell1.line1.hidden = YES;
            cell1.line2.hidden = YES;
            cell1.line3.hidden = NO;
            cell1.line4.hidden = YES;
            cell1.line5.hidden = YES;
            [cell1.SBBtn setTitleColor:[UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] forState:UIControlStateNormal];
            [cell1.KPBtn setTitleColor:[UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] forState:UIControlStateNormal];
            [cell1.RZBtn setTitleColor:[UIColor colorWithRed:0.97 green:0.38 blue:0.28 alpha:1] forState:UIControlStateNormal];
            [cell1.CSBtn setTitleColor:[UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] forState:UIControlStateNormal];
            [cell1.BSBtn setTitleColor:[UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] forState:UIControlStateNormal];
        }else if ([_level isEqualToString:@"tax"]) {
            cell1.line1.hidden = YES;
            cell1.line2.hidden = YES;
            cell1.line3.hidden = YES;
            cell1.line4.hidden = NO;
            cell1.line5.hidden = YES;
            [cell1.SBBtn setTitleColor:[UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] forState:UIControlStateNormal];
            [cell1.KPBtn setTitleColor:[UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] forState:UIControlStateNormal];
            [cell1.RZBtn setTitleColor:[UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] forState:UIControlStateNormal];
            [cell1.CSBtn setTitleColor:[UIColor colorWithRed:0.97 green:0.38 blue:0.28 alpha:1] forState:UIControlStateNormal];
            [cell1.BSBtn setTitleColor:[UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] forState:UIControlStateNormal];
        }else if ([_level isEqualToString:@"note"]) {
            cell1.line1.hidden = YES;
            cell1.line2.hidden = YES;
            cell1.line3.hidden = YES;
            cell1.line4.hidden = YES;
            cell1.line5.hidden = NO;
            [cell1.SBBtn setTitleColor:[UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] forState:UIControlStateNormal];
            [cell1.KPBtn setTitleColor:[UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] forState:UIControlStateNormal];
            [cell1.RZBtn setTitleColor:[UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] forState:UIControlStateNormal];
            [cell1.CSBtn setTitleColor:[UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] forState:UIControlStateNormal];
            [cell1.BSBtn setTitleColor:[UIColor colorWithRed:0.97 green:0.38 blue:0.28 alpha:1] forState:UIControlStateNormal];
            
        }
        return cell1;
        
    }else if (indexPath.section == 1) {
        //        static NSString *snap=@"snap";
        //        UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:snap];
        //        if (cell==nil) {
        //            cell=[[UITableViewCell  alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:snap];
        //        }
        //        // 设置cell不可点击
        //        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        //        // 删除重复的子控件
        //        [cell.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
        //
        //        // 设置左边图片
        //        firstView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 700)];
        //        firstView.backgroundColor = [UIColor whiteColor];
        //
        //        //123
        ////        _titScrollView = [[STSegmentView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 44)];
        ////        _titScrollView.delegate = self;
        ////        _titScrollView.titleArray = @[@"申报",@"开票",@"认证",@"财税",@"办税"];
        ////        _titScrollView.titleSpacing = 0;
        ////        _titScrollView.labelFont = [UIFont systemFontOfSize:15];
        ////        _titScrollView.bottomLabelTextColor = [UIColor blackColor];
        ////        _titScrollView.topLabelTextColor = [UIColor redColor];
        ////        _titScrollView.selectedBackgroundColor = [UIColor whiteColor];
        ////        _titScrollView.selectedBgViewCornerRadius = 0;
        ////        _titScrollView.sliderHeight = 3;
        ////        _titScrollView.sliderColor = [UIColor redColor];
        ////        _titScrollView.sliderTopMargin = 3;
        ////        _titScrollView.duration = 0.3;
        ////        [firstView addSubview:_titScrollView];
        //
        //        CGFloat tableViewW = self.view.width;
        //        CGFloat tableViewH = 980;
        //
        //        _homeScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_titScrollView.frame), tableViewW, tableViewH)];
        //        _homeScrollView.delegate = self;
        //        _homeScrollView.backgroundColor = [UIColor clearColor];
        //        _homeScrollView.contentSize = CGSizeMake(tableViewW * 1, tableViewH);
        //        _homeScrollView.pagingEnabled = YES;
        //        _homeScrollView.bounces = NO;
        //        [firstView addSubview:_homeScrollView];
        //
        //        NSArray *color = @[[UIColor greenColor],[UIColor yellowColor],[UIColor brownColor],[UIColor purpleColor],[UIColor redColor]];
        //        for (int i = 0; i < self.childViewControllers.count; i++) {
        //            UIViewController *vc = self.childViewControllers[i];
        //            vc.view.frame = CGRectMake(i * tableViewW, 0, tableViewW, tableViewH);
        //            vc.view.backgroundColor = color[i];
        //            [_homeScrollView addSubview:vc.view];
        //        }
        //        _titScrollView.outScrollView = _homeScrollView;
        //
        //        [cell addSubview:firstView];
        //
        //        return cell;
        
        cell2  = [[[NSBundle mainBundle] loadNibNamed:@"SBCell" owner:self options:nil] lastObject];
        cell2.selectionStyle = UITableViewCellSelectionStyleNone;//点击不变色
        cell2.Play_Click.tag = indexPath.row;
        cell2.wenBaCellLabel.tag = indexPath.row + 111111;
        cell2.delegate = self;
        if (self.WenBaListArray.count > 0 && self.WenBaListArray != nil) {
            
            cell2.titleLB.text = [self.WenBaListArray[indexPath.row] title];//标题
            [UILabel changeSpaceForLabel:cell2.titleLB];//设置字、行间距
            
            // ------ 自由行高
            CGSize maximumLbTitle = CGSizeMake(WSCREENH_WIDTH - 42, MAXFLOAT);//labelsize的最大值
            CGSize expectSize = [cell2.titleLB sizeThatFits:maximumLbTitle];
            
            if (expectSize.height == 22) {//如果单行时
                expectSize.height = 22;
            }//40

            if (expectSize.height > 60) {
                expectSize.height = 50;
            }

            cell2.cellTitH.constant = expectSize.height;
            cellTitH = expectSize.height;
            // ------ 自由行高

            cell2.fbsjLB.text = [self.WenBaListArray[indexPath.row] fbsj];
            cell2.viewLB.text = [NSString stringWithFormat:@"%@人看过",[self.WenBaListArray[indexPath.row] strView]];
           
            if ([WShareUtil strNilOrEmpty:[self.WenBaListArray[indexPath.row] audiosrc]]) {//判断有无音频字段(无)

                cell2.wenBaCellImang.image = [UIImage imageNamed:@"wenba_read"];
                cell2.wenBaCellLabel.text = @"点击查看";
                cell2.wenBaCellImang.hidden = YES;
                cell2.wenBaCellLabel.hidden = YES;
                
            }else{//（有）
                
                cell2.wenBaCellImang.image = [UIImage imageNamed:@"wenba_listen"];
                cell2.wenBaCellLabel.text = @"点击播放";
                
            }
            if ([[self.WenBaListArray[indexPath.row] isvip] isEqualToString:@"N"]) {
                cell2.isVip.hidden = YES;
            }else{
//                cell2.isVip.hidden = NO;//会员内容显示VIP
                cell2.isVip.hidden = YES;//都不显示VIP
            }

        }
        return cell2;
    }else if (indexPath.section == 2) {
        
        if ([_level2 isEqualToString:@"sb"]) {
            cell3  = [[[NSBundle mainBundle] loadNibNamed:@"SBFLCell" owner:self options:nil] lastObject];
            cell3.selectionStyle = UITableViewCellSelectionStyleNone;//点击不变色
            
            return cell3;
        }else if ([_level2 isEqualToString:@"kp"]) {
            cell4  = [[[NSBundle mainBundle] loadNibNamed:@"KPFLCell" owner:self options:nil] lastObject];
            cell4.selectionStyle = UITableViewCellSelectionStyleNone;//点击不变色
            
            return cell4;
        }else if ([_level2 isEqualToString:@"rz"]) {
            cell5  = [[[NSBundle mainBundle] loadNibNamed:@"RZFLCell" owner:self options:nil] lastObject];
            cell5.selectionStyle = UITableViewCellSelectionStyleNone;//点击不变色
            
            return cell5;
        }else if ([_level isEqualToString:@"tax"]) {
            cell6  = [[[NSBundle mainBundle] loadNibNamed:@"CSFLCell" owner:self options:nil] lastObject];
            cell6.selectionStyle = UITableViewCellSelectionStyleNone;//点击不变色
            
            return cell6;
        }else if ([_level isEqualToString:@"note"]) {
            cell7  = [[[NSBundle mainBundle] loadNibNamed:@"BSFLCell" owner:self options:nil] lastObject];
            cell7.selectionStyle = UITableViewCellSelectionStyleNone;//点击不变色
            
            return cell7;
        }
    }
    return nil;
}

//行点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        
    }else{
        
        CheckNetwork *checkNetwork = [[CheckNetwork alloc] init];
        if (![checkNetwork isNetworkReachable]) {//没网
            return;
        } else {
            // 都能进详情查看
            [tableView deselectRowAtIndexPath:indexPath animated:NO];

            if (self.WenBaListArray == nil || self.WenBaListArray.count <= 0) {
                return;
            }

            WLog(@"%@===========isfees",[self.WenBaListArray[indexPath.row] isfees]);
            WLog(@"%@===========isvip",[self.WenBaListArray[indexPath.row] isvip]);
            WLog(@"%@+++++++++++strlxmc",[WShareUtil sharedData].strlxmc);

//            // 对会员不收费， 对非会员收费
//            if ([[self.WenBaListArray[indexPath.row] isfees] isEqualToString:@"Y"] && [[self.WenBaListArray[indexPath.row] isvip] isEqualToString:@"N"] && [WShareUtil strNilOrEmpty: [WShareUtil sharedData].strlxmc]) {
//                WLog(@"对会员不收费， 对非会员收费");
//                return;
//            }
//
//            // 对会员也收费
//            if ([[self.WenBaListArray[indexPath.row] isfees] isEqualToString:@"Y"] && [[self.WenBaListArray[indexPath.row] isvip] isEqualToString:@"Y"]) {
//                WLog(@"对会员也收费");
//                return;
//            }
//
//            // 不收费， 但只能会员听
//            if ([[self.WenBaListArray[indexPath.row] isfees] isEqualToString:@"N"] && [[self.WenBaListArray[indexPath.row] isvip] isEqualToString:@"Y"] && [WShareUtil strNilOrEmpty: [WShareUtil sharedData].strlxmc]) {
//                WLog(@"不收费， 但只能会员听");
//                return;
//            }

            if ([[self.WenBaListArray[indexPath.row] isvip] isEqualToString:@"Y"] && [WShareUtil strNilOrEmpty: [WShareUtil sharedData].strlxmc] && [WShareUtil sharedData].dicSession) {
                UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"您还不是会员，加入会员即可查看!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
                [av show];
                return;
            }

            WLog(@"%@",[WShareUtil sharedData].dicSession);

            if ([[self.WenBaListArray[indexPath.row] isvip] isEqualToString:@"Y"] && [WShareUtil strNilOrEmpty: [WShareUtil sharedData].strlxmc] && ![WShareUtil sharedData].dicSession) {

                markIndex = indexPath.row;
                [WShareUtil sharedData].Who = @"AWBQX";
                LoginViewController *loginVc = [[LoginViewController alloc] init];
                [self.navigationController pushViewController:loginVc animated:YES];

            } else {

                WWebViewController *webVc = [[WWebViewController alloc] init];
                webVc.strTitle = @"问吧详情";

                webVc.shareTitle = [self.WenBaListArray[indexPath.row] title];//分享标题
                webVc.strID = [self.WenBaListArray[indexPath.row] ID];//分享ID
                webVc.strType = @"wz";//分享类型文章

                if (![WShareUtil strNilOrEmpty:[self.WenBaListArray[indexPath.row] link]] ) {
                    webVc.strUrl = [self.WenBaListArray[indexPath.row] link];
                }else{
                    webVc.strUrl = [self.WenBaListArray[0] link];
                }
                [self.navigationController pushViewController:webVc animated:YES];
            }
        }
    }
}

- (void)WBQXNOTICE {

    WLog(@"%@",[WShareUtil sharedData].dicSession);
    if ([WShareUtil sharedData].dicSession) {
        [WShareUtil sharedData].strlxmc = [WShareUtil sharedData].dicSession[@"lx_mc"];
    }

    if ([[self.WenBaListArray[markIndex] isvip] isEqualToString:@"Y"] && [WShareUtil strNilOrEmpty: [WShareUtil sharedData].strlxmc] && [WShareUtil sharedData].dicSession) {

        UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"您还不是会员，加入会员即可查看!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
        [av show];
        return;

    } else {
        WWebViewController *webVc = [[WWebViewController alloc] init];
        webVc.strTitle = @"问吧详情";
        webVc.shareTitle = [self.WenBaListArray[markIndex] title];//分享标题
        webVc.strID = [self.WenBaListArray[markIndex] ID];//分享ID
        webVc.strType = @"wz";//分享类型文章

        if (![WShareUtil strNilOrEmpty:[self.WenBaListArray[markIndex] link]] ) {
            webVc.strUrl = [self.WenBaListArray[markIndex] link];
        }else{
            webVc.strUrl = [self.WenBaListArray[0] link];
        }
        [self.navigationController pushViewController:webVc animated:YES];
    }
}

//分组个数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}

//列表行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0 || section == 2) {
        return 1;
    }else {

        return _WenBaListArray.count;
    }
    
}

//设置行高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.section == 0) {
        return 248;
    }else if (indexPath.section == 2) {
        return 120;
    }else{
        
        if (cellTitH == 22) {//单行
            return cellTitH + 35 + 10;
        }else{
            return cellTitH + 35 + 15;//(22+41)/40+41
        }
    }
    
}

//设置页眉
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    // 页眉视图
    headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 44)];
    headerView.backgroundColor = [UIColor yellowColor];
    
    
    
    // 分割线
    UILabel *lineLb = [[UILabel alloc]initWithFrame:CGRectMake(0, headerView.bounds.size.height - 1, [UIScreen mainScreen].bounds.size.width, 1)];
    lineLb.backgroundColor = [UIColor colorWithRed:0.91 green:0.93 blue:0.95 alpha:1];
    [headerView addSubview:lineLb];
    
    NSString *strTotal;
    NSMutableAttributedString *attri;
    //    if (_strtotal == nil||[_strtotal isEqualToString:@"null"]||[_strtotal isEqual:[NSNull null]]) {
    //        strTotal = @"";
    //    }else{
    //        strTotal = [NSString stringWithFormat:@"已更新%@期",_strtotal];
    //        attri = [[NSMutableAttributedString alloc] initWithString:strTotal];
    //        // 修改富文本中的不同文字的样式
    //        [attri addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:1 green:0.55 blue:0.18 alpha:1] range:NSMakeRange(3, strTotal.length - 4)];
    //        [attri addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(3, strTotal.length - 4)];
    //    }
    // 已更新
    UILabel *lb = [[UILabel alloc]initWithFrame:CGRectMake(13, 0, [UIScreen mainScreen].bounds.size.width, 20)];
    lb.font = [UIFont systemFontOfSize:16.0];
    lb.textColor = [UIColor colorWithRed:0.71 green:0.71 blue:0.71 alpha:1];
    lb.attributedText = attri;
    lb.textAlignment = NSTextAlignmentLeft;
    
    UIButton *paiXubtn = [UIButton buttonWithType:UIButtonTypeCustom];
    paiXubtn.frame = CGRectMake([UIScreen mainScreen].bounds.size.width-100, 0, 100, 40);
    paiXubtn.titleLabel.font = [UIFont systemFontOfSize:14.0];
    [paiXubtn setTitle:@"  排序" forState:UIControlStateNormal];
    [paiXubtn setTitleColor:[UIColor colorWithRed:0.71 green:0.71 blue:0.71 alpha:1] forState:UIControlStateNormal];
    [paiXubtn setTitleColor:[UIColor colorWithRed:0.71 green:0.71 blue:0.71 alpha:1] forState:UIControlStateSelected];
    if (isA) {
        [paiXubtn setImage:[UIImage imageNamed:@"sortup"] forState:UIControlStateNormal];
    }else {
        [paiXubtn setImage:[UIImage imageNamed:@"sortdown"] forState:UIControlStateNormal];
    }
    paiXubtn.tag = 890;
    [paiXubtn addTarget:self action:@selector(paiXubtn) forControlEvents:UIControlEventTouchUpInside];
    //    [headerView addSubview:lb];
    //    [headerView addSubview:paiXubtn];
    
    
    _titScrollView = [[STSegmentView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 44)];
    _titScrollView.delegate = self;
    _titScrollView.titleArray = @[@"申报",@"开票",@"认证",@"财税",@"办税"];
    _titScrollView.titleSpacing = 0;
    _titScrollView.labelFont = [UIFont systemFontOfSize:15];
    _titScrollView.bottomLabelTextColor = [UIColor blackColor];
    _titScrollView.topLabelTextColor = [UIColor redColor];
    _titScrollView.selectedBackgroundColor = [UIColor whiteColor];
    _titScrollView.selectedBgViewCornerRadius = 0;
    _titScrollView.sliderHeight = 3;
    _titScrollView.sliderColor = [UIColor redColor];
    _titScrollView.sliderTopMargin = 3;
    _titScrollView.duration = 0.3;
    //    [headerView addSubview:_titScrollView];
    
    return headerView;
}

//设置页眉的高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    //设置第一个section的header为0
    if (section==0) {
        return 0;
    }
    else{
        return 0;
    }
}
- (void)buttonClick:(NSInteger)index {
    [_homeScrollView setContentOffset:CGPointMake(self.view.width * index, 0) animated:NO];
}

-(void)Play_ClickBtn:(UIButton *)button {
    WLog(@"播放或详情");
    
    CheckNetwork *checkNetwork = [[CheckNetwork alloc] init];
    if (![checkNetwork isNetworkReachable]) {//没网
        return;
    } else {
        quanJuLb.text = @"正在加载";
        
        //    NSIndexPath *indexPath1 = [_myTableView indexPathForSelectedRow];
        WLog(@"%ld",button.tag);
        
        if (self.WenBaListArray == nil || self.WenBaListArray.count <= 0) {
            return;
        }

        WLog(@"%@===========isfees",[self.WenBaListArray[button.tag] isfees]);
        WLog(@"%@===========isvip",[self.WenBaListArray[button.tag] isvip]);
        WLog(@"%@+++++++++++strlxmc",[WShareUtil sharedData].strlxmc);

//        // 对会员不收费， 对非会员收费
//        if ([[self.WenBaListArray[button.tag] isfees] isEqualToString:@"Y"] && [[self.WenBaListArray[button.tag] isvip] isEqualToString:@"N"] && [WShareUtil strNilOrEmpty: [WShareUtil sharedData].strlxmc]) {
//            WLog(@"对会员不收费， 对非会员收费");
//            return;
//        }
//
//        // 对会员也收费
//        if ([[self.WenBaListArray[button.tag] isfees] isEqualToString:@"Y"] && [[self.WenBaListArray[button.tag] isvip] isEqualToString:@"Y"]) {
//            WLog(@"对会员也收费");
//            return;
//        }
//
//        // 不收费，但只能会员听
//        if ([[self.WenBaListArray[button.tag] isfees] isEqualToString:@"N"] && [[self.WenBaListArray[button.tag] isvip] isEqualToString:@"Y"] && [WShareUtil strNilOrEmpty: [WShareUtil sharedData].strlxmc]) {
//            WLog(@"不收费,但只能会员听");
//            return;
//        }

        if ([[self.WenBaListArray[button.tag] isvip] isEqualToString:@"Y"] && [WShareUtil strNilOrEmpty: [WShareUtil sharedData].strlxmc] && [WShareUtil sharedData].dicSession) {
            UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"您还不是会员，加入会员即可查看!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
            [av show];
            return;
        }


        if ([[self.WenBaListArray[button.tag] isvip] isEqualToString:@"Y"] && [WShareUtil strNilOrEmpty: [WShareUtil sharedData].strlxmc] && ![WShareUtil sharedData].dicSession) {

            markIndex = button.tag;
            [WShareUtil sharedData].Who = @"AWBQX";
            LoginViewController *loginVc = [[LoginViewController alloc] init];
            [self.navigationController pushViewController:loginVc animated:YES];

        } else {
            if ([WShareUtil strNilOrEmpty:[self.WenBaListArray[button.tag] audiosrc]]) {//无音频
                WLog(@"无音频跳详情");

                WWebViewController *webVc = [[WWebViewController alloc] init];
                webVc.strTitle = @"问吧详情";
                if (![WShareUtil strNilOrEmpty:[self.WenBaListArray[button.tag] link]] ) {
                    webVc.strUrl = [self.WenBaListArray[button.tag] link];
                }else{
                    webVc.strUrl = [self.WenBaListArray[0] link];
                }
                [self.navigationController pushViewController:webVc animated:YES];

            }else{//有音频

                button.selected = !button.selected;
                if (button.selected ||(![previousURL.absoluteString isEqualToString:[self.WenBaListArray[button.tag] audiosrc]] && ![WShareUtil strNilOrEmpty:previousURL.absoluteString])) {//选中
                    UILabel *find_label = (UILabel *)[self.view viewWithTag:(button.tag + 111111)];
                    find_label.text = @"正在加载";

                    [[AFSoundManager sharedManager]stop];//停播
                    WLog(@"选中");
                    WLog(@"000-%@",previousURL.absoluteString);
                    WLog(@"111-%@",[self.WenBaListArray[button.tag] audiosrc]);

                    if (![previousURL.absoluteString isEqualToString:[self.WenBaListArray[button.tag] audiosrc]] && ![WShareUtil strNilOrEmpty:previousURL.absoluteString] ) {
                        //播放音频
                        WLog(@"音频地址-%@",[self.WenBaListArray[button.tag] audiosrc]);
                        quanJuLb.text = @"点击播放";
                        [[AFSoundManager sharedManager]startStreamingRemoteAudioFromURL:[self.WenBaListArray[button.tag] audiosrc] andBlock:^(int percentage, CGFloat elapsedTime, CGFloat timeRemaining, NSError *error, BOOL finished) {
                            BF = YES;//播

                            if (button.tag<[self.WenBaListArray count])
                            {
                                previousURL = [NSURL URLWithString:[self.WenBaListArray[button.tag] audiosrc]];//以前url
                            }

                            UILabel *find_label = (UILabel *)[self.view viewWithTag:(button.tag + 111111)];
                            quanJuLb = find_label;
                            quanJuBt = button;
                            find_label.text = @"正在播放";

                        }];
                    }else if (button.selected ||(BF == YES && [previousURL.absoluteString isEqualToString:[self.WenBaListArray[button.tag] audiosrc]] && ![WShareUtil strNilOrEmpty:previousURL.absoluteString])){
                        [[AFSoundManager sharedManager]resume];//继续播
                        BF = NO;
                        UILabel *find_label = (UILabel *)[self.view viewWithTag:(button.tag + 111111)];
                        find_label.text = @"正在播放";
                    }
                }else {//未选中
                    WLog(@"未选中");

                    [[AFSoundManager sharedManager]pause];//暂停
                    UILabel *find_label = (UILabel *)[self.view viewWithTag:(button.tag + 111111)];
                    find_label.text = @"继续播放";
                }
            }
        }
    }
}

-(void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [[AFSoundManager sharedManager]pause];//暂停
    quanJuLb.text = @"继续播放";
    quanJuBt.selected = NO;
    
    [NavimgView removeFromSuperview];
}

#pragma mark - 问吧列表下分类条件跳转
-(void)PushAnswerSortListViewController {
    AnswerSortListViewController *aslVC = [[AnswerSortListViewController alloc]init];
    aslVC.level1 = [WShareUtil sharedData].AnswerSortListLevel1;
    aslVC.level2 = [WShareUtil sharedData].AnswerSortListLevel2;
    aslVC.level3 = [WShareUtil sharedData].AnswerSortListLevel3;
    aslVC.navTitle = [WShareUtil sharedData].AnswerSortNavTitle;
    [self.navigationController pushViewController:aslVC animated:YES];
}


#pragma mark - 下载列表数据
- (void)requestTJWB{
    
    [WShareUtil sharedData].isShowWait = NO;
    
    NSDictionary *parametersDict = @{@"mode":@"native",@"service":@"xxfb",@"content":@{@"revert":@"paginate",@"colcode":@"57",@"pagesize":@"10",@"pagenumber":@"1"}};
    NSString *secret = [NSString stringWithFormat:@"%@",[WHttpTool convertToJsonData:parametersDict]];
    
    [WHttpTool POST:[WShareUtil getServerURL:nil] parameters:@{@"params":[CommonFunc encryptWithText:secret]} success:^(id responseObject) {
        WLog(@"------%@",responseObject);
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *JsonDic = [WHttpTool dictionaryWithJsonString:responseStr];
        NSString *messageStr = [JsonDic objectForKey:@"message"];
        NSString *successStr = [JsonDic objectForKey:@"success"];
        // 解密请求回的数据（字典）
        NSString *returnStr = [CommonFunc decryptWithText:messageStr];
      
        // json字符串转字典
        NSDictionary *returnDic = [WHttpTool dictionaryWithJsonString:returnStr];
        
        WLog(@"%@",returnDic[@"data"]);
//        if (isRefresh) {
//            [[WShareUtil sharedData].arrMdiagram removeAllObjects];
//        }
        for (NSDictionary *dic in returnDic[@"data"]) {
            DiagramModel *diagramModel = [DiagramModel mj_objectWithKeyValues:dic];
            [[WShareUtil sharedData].arrMdiagram addObject:diagramModel];
        }
        
    } failure:^(NSError *error) {
        WLog(@"失败");
//        [self noWifiRefershingEnd];
    } showProgress:NO];
}

- (void)openMemberSheet {
    
    bgMebemView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WSCREENH_WIDTH, WSCREENH_HEIGHT)];
    bgMebemView.backgroundColor = WRGBAColor(0, 0, 0, 0.5);
    //    [self.view addSubview:bgMebemView];
    
    viewContent = [[UIView alloc] initWithFrame:CGRectMake((WSCREENH_WIDTH - 280) * 0.5, (WSCREENH_HEIGHT - 240) * 0.5, 280, 200)];
    viewContent.backgroundColor = WRGBColor(255, 255, 255);
    viewContent.layer.cornerRadius = 10;
    
    UILabel *lbTit = [[UILabel alloc] initWithFrame:CGRectMake(15, 12, 280-30, 50)];
    lbTit.backgroundColor = [UIColor whiteColor];
    lbTit.text = @"请根据您要咨询的问题，选择对应的问题类型";
    lbTit.font = [UIFont systemFontOfSize:15];
    lbTit.textAlignment = NSTextAlignmentCenter;
    lbTit.numberOfLines = 0;
    [viewContent addSubview:lbTit];
    
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 70, 280, 1)];
    lineView.backgroundColor = WRGBColor(243, 243, 243);
    [viewContent addSubview:lineView];
    
    UIButton *btnMember = [[UIButton alloc] initWithFrame:CGRectMake(0, 70, 280, 44)];
    [btnMember.titleLabel setFont:[UIFont systemFontOfSize:15]];
    [btnMember setTitle:@"防伪开票" forState:UIControlStateNormal];
    [btnMember setTitleColor:[UIColor colorWithRed:0 green:0.6 blue:0.92 alpha:1] forState:UIControlStateNormal];
    btnMember.tag = 100;
    [btnMember addTarget:self action:@selector(btnOpenClick:) forControlEvents:UIControlEventTouchUpInside];
    [viewContent addSubview:btnMember];
    
    UIView *lineView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 113, 280, 1)];
    lineView1.backgroundColor = WRGBColor(243, 243, 243);
    [viewContent addSubview:lineView1];
    
    UIButton *btnTourist = [[UIButton alloc] initWithFrame:CGRectMake(0, 114, 280, 44)];
    [btnTourist.titleLabel setFont:[UIFont systemFontOfSize:15]];
    [btnTourist setTitle:@"申报、认证等其他" forState:UIControlStateNormal];
    [btnTourist setTitleColor:[UIColor colorWithRed:0 green:0.6 blue:0.92 alpha:1] forState:UIControlStateNormal];
    btnTourist.tag = 110;
    [btnTourist addTarget:self action:@selector(btnOpenClick:) forControlEvents:UIControlEventTouchUpInside];
    [viewContent addSubview:btnTourist];
    
    UIView *lineView2 = [[UIView alloc] initWithFrame:CGRectMake(0, 157, 280, 1)];
    lineView2.backgroundColor = WRGBColor(243, 243, 243);
    [viewContent addSubview:lineView2];
    
    UIButton *btnLogin = [[UIButton alloc] initWithFrame:CGRectMake(0, 158, 280, 44)];
    [btnLogin.titleLabel setFont:[UIFont systemFontOfSize:15]];
    [btnLogin setTitle:@"取消" forState:UIControlStateNormal];
    [btnLogin addTarget:self action:@selector(btnOpenClick:) forControlEvents:UIControlEventTouchUpInside];
    btnLogin.tag = 120;
    [btnLogin setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [viewContent addSubview:btnLogin];
    
    [bgMebemView addSubview:viewContent];
    [[[UIApplication sharedApplication] delegate].window addSubview:bgMebemView];
    
    
}

- (void)btnOpenClick:(UIButton *)btn {
    if (btn.tag == 100) {
        
        WWebViewController *webVc = [[WWebViewController alloc] init];
        webVc.strTitle = @"开票客服";
        webVc.strUrl = @"http://www.sobot.com/chat/pc/index.html?sysNum=79f43fe7ebd049898175758d0b00d986";
        [self.navigationController pushViewController:webVc animated:YES];
        
    } else if (btn.tag == 110) {
        
        WWebViewController *webVc = [[WWebViewController alloc] init];
        webVc.strTitle = @"申报认证客服";
        webVc.strUrl = @"https://www.sobot.com/chat/h5/index.html?sysNum=f6a79964432e4eb1b2f70f92a6dfcbe4";
        [self.navigationController pushViewController:webVc animated:YES];
        
    } else {
        
    }
    [bgMebemView removeFromSuperview];
    [viewContent removeFromSuperview];
}

- (void)dealloc {
    //移除所有通知监控
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

@end
